using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using TVDesigner.GUI.Controls;

using Screen = TVDesigner.Entities.Elements.Screen;

namespace TVDesigner.GUI.Elements
{
    public partial class ScreenElement : TVDesigner.GUI.Elements.Element
    {
        private static int screenCount = 0;

        public ScreenElement() : this(null)
        {

        }
        public ScreenElement(TVDesigner.Entities.Elements.Screen sc)
        {
            InitializeComponent();

            this.Size = pictureBox1.Image.Size;

            if (sc != null)
            {
                _LogicElement = sc;
                _LogicElement.Size = this.Size;
                this.Name = sc.Name;
                this.Location = sc.Location;
            }
            else
            {
                _LogicElement = new TVDesigner.Entities.Elements.Screen();
                _LogicElement.Size = this.Size;
                _LogicElement.Location = this.Location;
                this.Name = "screen" + screenCount++;
                _LogicElement.Name = this.Name;
            }

            _Label.Text = this.Name;
            AddEvents(_Label);
            AddEvents(pictureBox1);
        }

        protected override void _RemoveElement()
        {
            ScreensPanel panel = this.Parent as ScreensPanel;
            panel.MainFrom.ListPropertyPanel.RemoveDiagram(this.LogicElement as Screen);
            panel.Controls.Remove(this);
        }

        private void Element_DoubleClick(object sender, EventArgs e)
        {
            ScreensPanel panel = this.Parent as ScreensPanel;
            panel.MainFrom.ShowDiagramTabControl(_LogicElement as Screen);
        }
    }
}

